package com.visizen.wisdomclass.server.client;

import com.visizen.wisdomclass.server.model.WcSessionUser;
import com.visizen.wisdomclass.server.model.WcSessionUserExample;
import com.visizen.wisdomclass.server.model.WcUser;
import com.visizen.wisdomclass.server.model.dto.SessionUserWithName;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;

import java.util.List;

public interface WcSessionUserMapper {

    @Select({"select", "wu.*",
            "from wc_session_user as wsu, wc_user as wu",
            "where wsu.user_id = wu.user_id and wsu.session_id = #{sessionId,jdbcType=BIGINT}",
            "group by wu.user_id"})
    @Results({
            @Result(column = "user_id", property = "user_id", jdbcType = JdbcType.BIGINT, id = true),
            @Result(column = "attach_id", property = "attach_id", jdbcType = JdbcType.BIGINT),
            @Result(column = "username", property = "username", jdbcType = JdbcType.VARCHAR),
            @Result(column = "passmd5", property = "passmd5", jdbcType = JdbcType.VARCHAR),
            @Result(column = "fullname", property = "fullname", jdbcType = JdbcType.VARCHAR),
            @Result(column = "sex", property = "sex", jdbcType = JdbcType.VARCHAR),
            @Result(column = "birthday", property = "birthday", jdbcType = JdbcType.DATE),
            @Result(column = "mobilephone", property = "mobilephone", jdbcType = JdbcType.VARCHAR),
            @Result(column = "email", property = "email", jdbcType = JdbcType.VARCHAR),
            @Result(column = "registertime", property = "registertime", jdbcType = JdbcType.TIMESTAMP) })
    List<WcUser> selectUserWithInfo(Long sessionId);

    /**
	 * This method was generated by MyBatis Generator. This method corresponds to the database table wc_session_user
	 * @mbggenerated
	 */
	@SelectProvider(type = WcSessionUserSqlProvider.class, method = "countByExample")
	int countByExample(WcSessionUserExample example);

	/**
	 * This method was generated by MyBatis Generator. This method corresponds to the database table wc_session_user
	 * @mbggenerated
	 */
	@DeleteProvider(type = WcSessionUserSqlProvider.class, method = "deleteByExample")
	int deleteByExample(WcSessionUserExample example);

	/**
	 * This method was generated by MyBatis Generator. This method corresponds to the database table wc_session_user
	 * @mbggenerated
	 */
	@Delete({ "delete from wc_session_user", "where id = #{id,jdbcType=BIGINT}" })
	int deleteByPrimaryKey(Long id);

	/**
	 * This method was generated by MyBatis Generator. This method corresponds to the database table wc_session_user
	 * @mbggenerated
	 */
	@Insert({ "insert into wc_session_user (id, session_id, ",
			"user_id, jointime, ", "iscontacts)",
			"values (#{id,jdbcType=BIGINT}, #{session_id,jdbcType=BIGINT}, ",
			"#{user_id,jdbcType=BIGINT}, #{jointime,jdbcType=TIMESTAMP}, ",
			"#{iscontacts,jdbcType=INTEGER})" })
	int insert(WcSessionUser record);

	/**
	 * This method was generated by MyBatis Generator. This method corresponds to the database table wc_session_user
	 * @mbggenerated
	 */
	@InsertProvider(type = WcSessionUserSqlProvider.class, method = "insertSelective")
	int insertSelective(WcSessionUser record);

	/**
	 * This method was generated by MyBatis Generator. This method corresponds to the database table wc_session_user
	 * @mbggenerated
	 */
	@SelectProvider(type = WcSessionUserSqlProvider.class, method = "selectByExample")
	@Results({
			@Result(column = "id", property = "id", jdbcType = JdbcType.BIGINT, id = true),
			@Result(column = "session_id", property = "session_id", jdbcType = JdbcType.BIGINT),
			@Result(column = "user_id", property = "user_id", jdbcType = JdbcType.BIGINT),
			@Result(column = "jointime", property = "jointime", jdbcType = JdbcType.TIMESTAMP),
			@Result(column = "iscontacts", property = "iscontacts", jdbcType = JdbcType.INTEGER) })
	List<WcSessionUser> selectByExample(WcSessionUserExample example);

	/**
	 * This method was generated by MyBatis Generator. This method corresponds to the database table wc_session_user
	 * @mbggenerated
	 */
	@Select({ "select", "id, session_id, user_id, jointime, iscontacts",
			"from wc_session_user", "where id = #{id,jdbcType=BIGINT}" })
	@Results({
			@Result(column = "id", property = "id", jdbcType = JdbcType.BIGINT, id = true),
			@Result(column = "session_id", property = "session_id", jdbcType = JdbcType.BIGINT),
			@Result(column = "user_id", property = "user_id", jdbcType = JdbcType.BIGINT),
			@Result(column = "jointime", property = "jointime", jdbcType = JdbcType.TIMESTAMP),
			@Result(column = "iscontacts", property = "iscontacts", jdbcType = JdbcType.INTEGER) })
	WcSessionUser selectByPrimaryKey(Long id);

	/**
	 * This method was generated by MyBatis Generator. This method corresponds to the database table wc_session_user
	 * @mbggenerated
	 */
	@UpdateProvider(type = WcSessionUserSqlProvider.class, method = "updateByExampleSelective")
	int updateByExampleSelective(@Param("record") WcSessionUser record,
			@Param("example") WcSessionUserExample example);

	/**
	 * This method was generated by MyBatis Generator. This method corresponds to the database table wc_session_user
	 * @mbggenerated
	 */
	@UpdateProvider(type = WcSessionUserSqlProvider.class, method = "updateByExample")
	int updateByExample(@Param("record") WcSessionUser record,
			@Param("example") WcSessionUserExample example);

	/**
	 * This method was generated by MyBatis Generator. This method corresponds to the database table wc_session_user
	 * @mbggenerated
	 */
	@UpdateProvider(type = WcSessionUserSqlProvider.class, method = "updateByPrimaryKeySelective")
	int updateByPrimaryKeySelective(WcSessionUser record);

	/**
	 * This method was generated by MyBatis Generator. This method corresponds to the database table wc_session_user
	 * @mbggenerated
	 */
	@Update({ "update wc_session_user",
			"set session_id = #{session_id,jdbcType=BIGINT},",
			"user_id = #{user_id,jdbcType=BIGINT},",
			"jointime = #{jointime,jdbcType=TIMESTAMP},",
			"iscontacts = #{iscontacts,jdbcType=INTEGER}",
			"where id = #{id,jdbcType=BIGINT}" })
	int updateByPrimaryKey(WcSessionUser record);
}